﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class selectseat : System.Web.UI.Page
{
    protected string source = "";
    protected string channel = "";
    protected string strSeat = "";
    protected string[] zhiwu = { "heise", "shenmise" };
    //protected string[] zhiwu = { "织物座椅_黑色", "织物座椅_深米色" };
    protected string[] zhenpi = { "chunhei", "mise", "heilan", "honghei" };
    //protected string[] zhenpi = { "真皮座椅_纯黑", "真皮座椅_米色", "真皮座椅_黑色-蓝色(双色)", "真皮座椅_红色-黑色(双色)" };
    protected string[] colorValues = { "zhenghei", "tangguobai", "niuzailan", "jufenghong", "taifeihe", "bojinhui", "xuanmuyin", "shenhei", "lingyangbai" };
    //protected string[] colorValues = { "标准漆_正黑", "标准漆_糖果白", "标准漆_牛仔蓝", "标准漆_飓风红", "金属漆_太妃褐", "金属漆_铂金灰", "金属漆_眩目银", "珠光漆_深黑", "珠光漆_羚羊白" };
    protected int[] num = { 4, 3, 3, 2, 2, 4, 4, 4, 4 };
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["source"]))
            source = Request.QueryString["source"];
        if (!string.IsNullOrEmpty(Request.QueryString["channel"]))
            channel = Request.QueryString["channel"];

        if (!string.IsNullOrEmpty(Request.QueryString["model"]) && !string.IsNullOrEmpty(Request.QueryString["capcity"]) && !string.IsNullOrEmpty(Request.QueryString["color"]))
        {
            string capcity = Request.QueryString["capcity"];//排量
            string model = Request.QueryString["model"];//车型
            string color = Request.QueryString["color"];//颜色
            string[] seat = new string[6];

            if (color == "tuxinghuang")//处理特殊颜色
            {
                if (model == "时尚型")
                    seat.SetValue(zhiwu[0], 0);
                else
                    seat.SetValue(zhenpi[0], 0);
            }
            else
            {
                if (color == "jiaoshilan")//处理特殊颜色
                {
                    if (model == "时尚型")
                    {
                        if (capcity == "1.4TSI")
                        {
                            seat.SetValue(zhenpi[0], 0);//真皮座椅_纯黑
                        }
                        else
                        {
                            seat.SetValue(zhenpi[0], 0);
                            seat.SetValue(zhenpi[1], 1);
                            seat.SetValue(zhenpi[2], 2);
                        }
                    }
                }
                else
                {//非特殊颜色
                    for (int i = 0; i < colorValues.Length; i++)//遍历出用户选择的颜色
                    {
                        if (color == colorValues[i])
                        {
                            if (model == "时尚型")
                            {
                                seat = zhiwu;
                            }
                            else
                            {
                                for (int j = 0; j < num[i]; j++)//遍历座椅颜色所对应的个数
                                {
                                    seat.SetValue(zhenpi[j], j);
                                }
                            }
                        }
                    }
                }
            }

            //循环座椅html码
            foreach (string name in seat)
            {
                if (!string.IsNullOrEmpty(name))
                {
                    strSeat += "<a href=\"RegInfo.aspx?utm_source=" + source + "&utm_medium="+channel+"&source=" + source + "&channel=" + channel + "&seat=" + name + "&capcity=" + capcity + "&model=" + model + "&color=" + color + "\" title=\"" + name + "\"><img src=\"images/" + name + ".jpg\" alt=\"" + name + "\" /></a>";
                }
            }
        }
        else
        {
            Response.Redirect("Default.aspx");
        }
    }
}